// written by Jonathan Odom and Aneesh Butani

#include "HTMLOutputter.h";
#include "event.h"
#include "appt.h"
#include "XMLParser.h"
#include <iostream>
#include <cctype>
#include <algorithm>
#include <sstream>
#include "Comparator.h"

const string f = "-f";

int main(int argc, char* argv[]){
	string filter="";

	if(argc==3) {
		stringstream s;
		s<<argv[1];
		string argv1=s.str();
		if(argv1==f)
		{
			stringstream s2;
			s2<<argv[2];
			filter=s2.str();
		}
	}
	
	Appt a = Appt(912, 19.5, 20, "meeting with Alex");
	cout << a.getDay() << " " << a.getDescription() << " " << a.getStart() << " " << a.getEnd()<<endl;
	cout << "reading in source.xml (Appt)" << endl;
	int whichEvent = 2;
	//cin >> whichEvent;
	//cout << "reading in source.xml";
	XMLParser parser("source2.xml", whichEvent);
	vector<Event> testEvents = parser.getEvents(filter);
	
	//cout << "reading in source2.xml" << endl;
	//parser("source2.xml", 2);
		
	//testEvents. = parser.getEvents();
	//cerr << (testEvents.at(0)).getDescription();
	//testEvents.pop_back();
	sort(testEvents.begin(), testEvents.end(), Comparitor<Event> (new Sorter<Event>()));
	for(unsigned int k = 0; k< testEvents.size(); k++)
	{
		Event a = testEvents.at(k);
		cout << a.getDay() << " " << a.getDescription()<<endl;
	}
	
	HTMLOutputter b;
	b.StandardTable(testEvents);
	return 0;
	
}
